<?php
ini_set('display_errors', 'on');

$require = array(
	"controller/controller.php",
	"model/database.php",
	"view/gui.php"
);

for($i=0; $i<count($require); $i++){
	if(file_exists($require[$i])){
		require($require[$i]);
	}
	else{
		print "Error: REQUIRE FILE ".($i+1);
		exit;
	}
}

session_start();

$url = !empty($_GET["url"]) ? $_GET["url"] : "start";
$url = rtrim($url, "/");
$url = explode("/", $url);

if(!file_exists("controller/".$url[0].".php")){
	header("Location: index.php?url=error/404/".implode("/", $url));
}

require("controller/".$url[0].".php");

$controller = new $url[0]($url);
$controller->start();
?>
